import os
import logging
import datetime


def get_local_time():
    cur = datetime.datetime.now()
    cur = cur.strftime('%Y-%m-%d_%H-%M-%S')

    return cur


def logging_setting(args):
    if not os.path.exists('./log'):
        os.mkdir('./log')
    if not os.path.exists('./log/' + args.model):
        os.mkdir('./log/' + args.model)
    log_format = "%(asctime)s - %(levelname)s - %(message)s"
    data_format = "%m/%d/%Y %H:%M:%S"

    log_name = './log/{}/{}-{}-{}-[{}].log'.format(args.model, args.model, args.version, get_local_time(), args.log_comment)
    logging.basicConfig(
        level=logging.DEBUG,
        format=log_format,
        datefmt=data_format,
        handlers=[logging.FileHandler(log_name), logging.StreamHandler()])
    return log_name
